//
//  BusinessCooseCell.m
//  NewPro
//
//  Created by 何荧红 on 2018/12/27.
//  Copyright © 2018 何荧红. All rights reserved.
//

#import "BusinessCooseCell.h"

@interface BusinessCooseCell ()
@property (nonatomic, assign) BOOL posstatus;//是否能展开
@property (nonatomic, strong) UILabel *number;
@property (nonatomic, strong) UILabel *money;
@property (nonatomic, strong) UIImageView *searimg;

@end

@implementation BusinessCooseCell
- (void)setInfodic:(NSDictionary *)infodic{
    _infodic = infodic;
    if (_infodic.count > 0) {
        self.number.text = [[_infodic allKeys] firstObject];
        NSInteger moneyl = [[[_infodic allValues] firstObject][0] integerValue];
        self.money.text = [NSString stringWithFormat:@"0-%ld",moneyl];
        if ([[[_infodic allValues] firstObject][1][@"clik"] isEqualToString:@"0"]) {
            self.searimg.image = [UIImage imageNamed:@"SN未选择"];
        }else if([[[_infodic allValues] firstObject][1][@"clik"] isEqualToString:@"1"]){
            self.searimg.image = [UIImage imageNamed:@"SN已选择"];
        }
    }
}
- (void)setIndexarr:(NSMutableArray *)indexarr{
    _indexarr = indexarr;
    if (_indexarr.count > 0) {
        [self CleanSelfWith:self.indexarr];
    }
}
- (void)CleanSelfWith:(NSMutableArray *)arr{
    UIView *view1 = arr[0];
    UIView *view2 = arr[1];
    UIView *view3 = arr[2];
    UIView *view4 = arr[3];
    [_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(11);
        make.centerX.equalTo(self.mas_left).offset(view1.center.x);
        make.height.mas_equalTo(8);
    }];
    [_number mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.title.mas_centerY);
        make.left.equalTo(self.mas_left).offset(view2.frame.origin.x);
        make.height.mas_equalTo(20);
    }];
    
    [self.money mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.title.mas_centerY);
        make.centerX.equalTo(self.mas_left).offset(view4.center.x);
    }];
    [self.searimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(14);
        make.width.mas_equalTo(14);
        make.centerY.equalTo(self.title.mas_centerY);
        make.centerX.equalTo(self.mas_left).offset(view3.center.x);
    }];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 20);
        [self CleanDefaultView];
    }
    return self;
}
- (void)CleanDefaultView{
    self.title = [[UILabel alloc]init];
    self.title.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
    self.title.textColor = [UIColor colorWithHexString:@"666666"];
    [self addSubview:self.title];
    self.number = [[UILabel alloc]init];
    self.number.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
    self.number.textColor = [UIColor colorWithHexString:@"666666"];
    [self addSubview:self.number];
    self.money = [[UILabel alloc]init];
    self.money.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
    self.money.textColor = [UIColor colorWithHexString:@"333333"];
    [self addSubview:self.money];
    self.searimg = [[UIImageView alloc]init];
    self.searimg.image = [UIImage imageNamed:@"SN未选择"];
    [self addSubview:self.searimg];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
